package com.ruoyi.system.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.TbShoppingCarts;
import com.ruoyi.system.mapper.TbShoppingCartsMapper;
import com.ruoyi.system.service.ITbShoppingCartsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 购物车Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-04-07
 */
@Service
public class TbShoppingCartsServiceImpl implements ITbShoppingCartsService 
{
    @Autowired
    private TbShoppingCartsMapper tbShoppingCartsMapper;

    /**
     * 查询购物车
     * 
     * @param id 购物车主键
     * @return 购物车
     */
    @Override
    public TbShoppingCarts selectTbShoppingCartsById(Long id)
    {
        return tbShoppingCartsMapper.selectTbShoppingCartsById(id);
    }

    /**
     * 查询购物车列表
     * 
     * @param tbShoppingCarts 购物车
     * @return 购物车
     */
    @Override
    public List<TbShoppingCarts> selectTbShoppingCartsList(TbShoppingCarts tbShoppingCarts)
    {
        return tbShoppingCartsMapper.selectTbShoppingCartsList(tbShoppingCarts);
    }

    /**
     * 新增购物车
     * 
     * @param tbShoppingCarts 购物车
     * @return 结果
     */
    @Override
    public int insertTbShoppingCarts(TbShoppingCarts tbShoppingCarts)
    {
        tbShoppingCarts.setCreateTime(DateUtils.getNowDate());
        return tbShoppingCartsMapper.insertTbShoppingCarts(tbShoppingCarts);
    }

    /**
     * 修改购物车
     * 
     * @param tbShoppingCarts 购物车
     * @return 结果
     */
    @Override
    public int updateTbShoppingCarts(TbShoppingCarts tbShoppingCarts)
    {
        tbShoppingCarts.setUpdateTime(DateUtils.getNowDate());
        return tbShoppingCartsMapper.updateTbShoppingCarts(tbShoppingCarts);
    }

    /**
     * 批量删除购物车
     * 
     * @param ids 需要删除的购物车主键
     * @return 结果
     */
    @Override
    public int deleteTbShoppingCartsByIds(Long[] ids)
    {
        return tbShoppingCartsMapper.deleteTbShoppingCartsByIds(ids);
    }

    /**
     * 删除购物车信息
     * 
     * @param id 购物车主键
     * @return 结果
     */
    @Override
    public int deleteTbShoppingCartsById(Long id)
    {
        return tbShoppingCartsMapper.deleteTbShoppingCartsById(id);
    }
}
